<%@ taglib prefix="spring-tags" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="spring-form" uri="http://www.springframework.org/tags/form"%>
<%@ page
    import="org.jiscinvolve.astrodabis.barberry.control.Paths"
    import="org.jiscinvolve.astrodabis.barberry.control.ObjectData"
    import="org.jiscinvolve.astrodabis.barberry.control.RequestData"
    import="org.jiscinvolve.astrodabis.barberry.common.core.Job"
    import="org.jiscinvolve.astrodabis.barberry.common.core.Tag"
    import="org.jiscinvolve.astrodabis.barberry.common.core.Account"
    import="org.jiscinvolve.astrodabis.barberry.common.data.RowTag"
    import="org.jiscinvolve.astrodabis.barberry.common.data.JoinTag"
    import="org.jiscinvolve.astrodabis.barberry.common.data.TapRow"
    import="org.jiscinvolve.astrodabis.barberry.common.data.TapJoin"
    import="org.jiscinvolve.astrodabis.barberry.common.data.TapColumn"
    session="true"
%><%
ObjectData<Job> data = (ObjectData<Job>) request.getAttribute(
    RequestData.MODEL_ATTRIB
    ) ;
Account actor = data.actor();
Job job  = data.object();
%>
<html>
    <head>
	    <title>AstroDAbis DataSet <%= job.ident() %></title>
        <link href='<%= data.file("css/page.css") %>' rel='stylesheet' type='text/css'/>
    </head>
    <body>
        <%@ include file="/jsp/header.jsp" %>
        <div class='body'>
            <div class='left'>
                <%@ include file="/jsp/menu.jsp" %>
            </div>
            <div class='right'>
                <a href='<%= data.link(job) %>'>
                    <img src='<%= data.qrcode(data.link(job)) %>'/>
                </a>
            </div>
            <div class='content'>
        	    <h2>DataSet <%= job.name() %></h2>
                <fieldset>
                    <legend>Details</legend>
                    <div>
                        <ul>
                            <li>
                                Owner : <a href='<%= data.link(job.owner()) %>'><%= job.owner().name() %></a>
                            </li>
                            <li>
                                Name : <%= job.name() %>
                            </li>
                            <li>
                                Status : <%= job.status() %>
                            </li>
                            <li>
                                Type : <%= job.annotType() %>
                            </li>
                            <li>
                                Row count : <%= job.count() %>
                            </li>
                        </ul>
                    </div>
                </fieldset>
                <fieldset>
                    <legend>Description</legend>
                    <div>
                        <%= job.text() %>
                    </div>
                    <%
                    if ((actor != null) && (actor.equals(job.owner())))
                        {
                        %>
                        <a href='<%= data.link(job, "edit") %>'>[edit]</a>
                        <%
                        }
                    %>
                </fieldset>
                <fieldset>
                    <legend>Tags</legend>
                    <table>
                        <%
                        for (Tag tag : job.tags().select())
                            {
                            %>
                            <tr>
                                <td>
                                    <a href="<%= data.link(tag) %>"><%= tag.owner().name() %>:<%= tag.name() %></a>
                                </td>
                                <td>
                                    <%= tag.text() %>
                                </td>
                            </tr>
                            <%
                            }
                        %>
                    </table>
                </fieldset>
                <fieldset>
                    <legend>Row tags</legend>
                    <table>
                        <%
                        for (RowTag rowtag : job.rowtags().select())
                            {
                            %>
                            <tr>
                                <td>
                                    <a href="<%= data.link(rowtag.row().parent().parent()) %>"><%= rowtag.row().parent().parent().name() %></a>
                                </td>
                                <td>
                                    <a href="<%= data.link(rowtag.row().parent()) %>"><%= rowtag.row().parent().name() %></a>
                                </td>
                                <td>
                                    <a href="<%= data.link(rowtag.row()) %>"><%= rowtag.row().value() %></a>
                                </td>
                                <td>
                                    <a href="<%= data.link(rowtag.tag()) %>"><%= rowtag.tag().owner().name() %>:<%= rowtag.tag().name() %></a>
                                </td>
                                <td>
                                    <%= (rowtag.value() != null) ? rowtag.value() : "-" %>
                                </td>
                            </tr>
                            <%
                            }
                        %>
                    </table>
                </fieldset>

                <fieldset>
                    <legend>Join tags</legend>
                    <table>
                        <%
                        for (JoinTag jointag : job.jointags().select())
                            {
                            %>
                            <tr>
                                <td>
                                    <a href="<%= data.link(jointag.join()) %>"><%= jointag.join().ident() %></a>
                                </td>
                                <td>
                                    <a href="<%= data.link(jointag.tag()) %>"><%= jointag.tag().name() %></a>
                                </td>
                                <td>
                                    <%= (jointag.value() != null) ? jointag.value() : "-" %>
                                </td>
                            </tr>
                            <%
                            }
                        %>
                    </table>
                </fieldset>

            </div>
        </div>
        <%@ include file="/jsp/footer.jsp" %>
    </body>
</html>

